Skip to content

fix: include git2/sys/alloc.h for git_allocator on libgit2 1.8+#512

Closed
eejd wants to merge 1 commit into
DeusData:mainfrom
eejd:fix/libgit2-sys-alloc-include
Closed

fix: include git2/sys/alloc.h for git_allocator on libgit2 1.8+#512
eejd wants to merge 1 commit into
DeusData:mainfrom
eejd:fix/libgit2-sys-alloc-include

Conversation

@eejd

@eejd eejd commented Jun 19, 2026

Copy link
Copy Markdown

Problem

git_allocator was moved from the top-level git2.h into git2/sys/alloc.h
in libgit2 1.8.0. Building codebase-memory-mcp against libgit2 ≥ 1.8 fails:

internal/cbm/cbm.c:347:12: error: unknown type name 'git_allocator'

Fix

Add an explicit #include <git2/sys/alloc.h> immediately after
#include <git2.h> inside the HAVE_LIBGIT2 guard in
internal/cbm/cbm.c. The struct members (gmalloc, grealloc, gfree)
and the GIT_OPT_SET_ALLOCATOR option code are unchanged — the only
issue was the missing header.

Tested against

  • libgit2 1.9.4 (MacPorts, macOS / Apple Silicon)

🤖 Generated with Claude Code

git_allocator moved out of the top-level git2.h into git2/sys/alloc.h
in libgit2 1.8.0. Add an explicit include so the mimalloc binding
compiles against libgit2 >= 1.8 (e.g. MacPorts libgit2 1.9.4).
@DeusData

Copy link
Copy Markdown
Owner

Thanks @eejd — the git2/sys/alloc.h include for libgit2 1.8+ is correct. The only thing blocking is DCO: the commit's author email doesn't match its Signed-off-by email, so the DCO check fails. Could you re-sign with a matching identity — git commit --amend -s (with the author email equal to your sign-off email), or git rebase --signoff — then force-push? Once DCO is green I'll merge. 🙏

PR9000 added a commit to PR9000/codebase-memory-mcp that referenced this pull request Jun 28, 2026
    This resolves build failures against libgit2 >= 1.8.0.
    Co-authored-by: @eejd (based on pending PR DeusData#512)
@DeusData DeusData added bug Something isn't working priority/normal Standard review queue; useful PR with ordinary maintainer urgency. labels Jun 29, 2026
@DeusData

DeusData commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Thanks for the libgit2 compatibility fix. Before review can continue, please add a DCO Signed-off-by trailer to the non-merge commit and remove any generated/session attribution from commit metadata.

@nilbot

nilbot commented Jul 2, 2026

Copy link
Copy Markdown

Confirming this fix on another environment — thanks for putting it up.

Repro (macOS arm64, Homebrew libgit2 1.9.4): scripts/build.sh --with-ui fails at the final link step with

internal/cbm/cbm.c:347:12: error: unknown type name 'git_allocator'
  347 |     static git_allocator cbm_git_alloc = {

On libgit2 1.9.4, <git2.h>common.h only mentions git_allocator in a doc comment; the typedef struct { … } git_allocator; itself lives in the plumbing header git2/sys/alloc.h, which <git2.h> doesn't pull in. Adding #include <git2/sys/alloc.h> (exactly this PR) makes it compile and link cleanly, and the resulting binary indexes normally.

So this reproduces beyond 1.8+ (also on 1.9.4), and the fix is correct. It looks merge-ready aside from the DCO Signed-off-by trailer — would be great to see it land, since main currently doesn't build against a Homebrew libgit2 without it.

@DeusData

DeusData commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Thank you for finding and reporting this first — you identified the missing include a full 11 days before anyone else, and that diagnosis is what ultimately got it fixed. We've merged the same fix via #722 (merge efad17d), which was in a mergeable state with a passing DCO check; since the sign-off here never came through and the branch went quiet, we're closing this one as a duplicate rather than leaving it open. The first-finder credit is yours — thanks again for the sharp catch, and we'd be happy to see more contributions from you.

@DeusData DeusData closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority/normal Standard review queue; useful PR with ordinary maintainer urgency.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants